package com.kly.user.enums;

import java.util.Objects;

/**
 * 推送类型
 * @author linqu
 */
public enum EventPushType {

    OnlyPushEvent("OnlyPushEvent", "推送事件", 1),
    PushData("PushData", "推送值", 2),
    PushDataAndIncome("PushDataAndIncome",  "推送值和收入", 3),;
    private final String eventCode;

    private final String description;
    /**
     * 1-只推送事件 2-只推送值 3-推送值和收入
     */
    private final Integer type;

    public Integer getType() {
        return type;
    }

    EventPushType(String eventCode, String description, Integer type) {
        this.eventCode = eventCode;
        this.description = description;
        this.type = type;
    }

    public String getEventCode() {
        return eventCode;
    }

    public String getDescription() {
        return description;
    }


    public static EventPushType fromCode(String type) {
        if (Objects.isNull(type)) {
            return null;
        }
        for (EventPushType userStatus : values()) {
            if (userStatus.getEventCode().equalsIgnoreCase(type)) {
                return userStatus;
            }
        }
        return null;
    }
}
